<template>
  <div>
    <!-- 头部部分 -->
    <header class="header">
      <h1>todos</h1>
      <input
        @keyup.enter="add"
        v-model.trim="values"
        class="new-todo"
        placeholder="请输入任务名称"
        autofocus
      />
    </header>
  </div>
</template>

<script>
import { mapActions } from "vuex";
export default {
  data() {
    return {
      values: ""
    };
  },
  methods: {
    ...mapActions("list", ["additem"]),
    //添加
    add() {
      if (!this.values) {
        alert("请输入内容");
        return;
      }
      this.additem({
        name: this.values,
        isDone: false
      });
      this.values = "";
    }
  }
};
</script>

<style>
</style>